<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>养殖户主页</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">

<div class="container py-5">
    <div class="text-center mb-4">
        <h2 class="text-success">🐟 智慧海洋牧场养殖控制台</h2>
        <p class="lead">欢迎，{{ session.username }}（养殖户）</p>
    </div>

    <div class="row g-4">
        <!-- 控制功能 -->
        <div class="col-md-6">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">养殖操作</div>
                <div class="card-body text-center">
                    <button class="btn btn-success m-2" onclick="sendCommand('feed')">投喂</button>
                    <button class="btn btn-info m-2" onclick="sendCommand('oxygen')">开启增氧机</button>
                    <button class="btn btn-warning m-2" onclick="sendCommand('stop')">停止设备</button>
                </div>
            </div>
        </div>

        <!-- 日志信息 -->
        <div class="col-md-6">
            <div class="card shadow">
                <div class="card-header bg-secondary text-white">养殖日志</div>
                <div class="card-body">
                    <ul class="list-group">
                        <li class="list-group-item">[10:00] 成功投喂</li>
                        <li class="list-group-item">[10:30] 开启增氧机</li>
                        <li class="list-group-item">[11:00] 设备停止运行</li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div class="text-center mt-4">
        <a href="{{ url_for('logout') }}" class="btn btn-outline-danger">退出登录</a>
    </div>
</div>

<script>
function sendCommand(action) {
  fetch(`/api/control?act=${action}`)
    .then(res => res.text())
    .then(msg => alert(msg));
}
</script>

</body>
</html>
